<?php 
include("includes/code_admin.php");
if (isset($_GET['id'])) {$id = $_GET['id'];}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title><?php echo SITEURL; ?> Administrator</title>
<link href="style_admin.css" rel="stylesheet" type="text/css" />
<!-- TinyMCE -->
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "jbimages,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,|,jbimages",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Bu kod rasm yuklash plugini uchun (jbimages plugini)
        relative_urls : false,
		
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "tinymce/examples/lists/template_list.js",
		external_link_list_url : "tinymce/examples/lists/link_list.js",
		external_image_list_url : "tinymce/examples/lists/image_list.js",
		media_external_list_url : "tinymce/examples/lists/media_list.js",

		// Style formats
		style_formats : [
			{title : 'Bold text', inline : 'b'},
			{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
			{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
			{title : 'Example 1', inline : 'span', classes : 'example1'},
			{title : 'Example 2', inline : 'span', classes : 'example2'},
			{title : 'Table styles'},
			{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
		],

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
</script>
<!-- /TinyMCE -->
</head>

<body>
<div id="container">
<table class="main" cellspacing="0" cellpadding="0">
  <tr>
    <td class="header">
    <!-- header start -->
    <?php include("includes/header.php");?>
    <!-- header finish -->
    </td>
  </tr>
  <tr>
    <td class="middle">&nbsp;</td>
  </tr>
  <tr>
    <td>
    <!-- tepa start -->
<?php include("includes/tepa.php"); ?>
    <!-- tepa finish -->
    </td>
  </tr>
  <tr>
    <td>
    <!-- contant start -->
<table class="content" cellspacing="0" cellpadding="0">
  <tr valign="top">
    <td>
    <!-- right col -->
<div class="right_col">
<h3 class="title">Sahifani o'zgartirish</h3>

<?php 
if(isset($_POST['send']))
{
	$id = $_POST['id'];
	$title = addslashes($_POST['title']);
	$izoh = addslashes($_POST['izoh']);
	$text = addslashes($_POST['text']);
	$img_link = $_POST['img'];
	
	if(trim($title) == '')
    {
	$error = "DIQQAT !!! Sarlavhani yozing";
    }
	else if(trim($text) == '')
    {
       $error = ' Matn yozmadingiz!';
    }
	if($error == '')
	{
	/****** RASM YUKLASH KODI *****/
	include("includes/img_upload_news.php");
	/***** RASM YUKLASH KODI TAMOM ******/
	
		$result3 = mysql_query("UPDATE news SET title_news='$title', izoh_news='$izoh', text_news='$text', img_news='$img_link' WHERE id_news='$id'");
		 if($result3=='true') 
		 { 
		 echo "<p class='ok'>Maqola Qo'shildi, OK... ".$yuklandi.$yuklanmadi.$yuborilmadi."</p>";
		 echo "<br><center><a href = 'news.php'> <b>Yana O'zgartirish</b> </a> </center>";
		 }
		 else 
		 { 
		 myerror("Afsuski Maqola qo'shilmadi, Qayta tekshiring. "); 
		 }
	}
}

if(!isset($_POST['send']) || $error != '')
{
echo "<p style='color:#FF0000'><b> $error </b></p>";

$result = mysql_query("SELECT id_news, title_news, izoh_news, text_news, img_news FROM news WHERE id_news='$id' ");
if (!$result)
{ myerror("News jadvalidan malumotlar olinmadi..."); }

$myrow = mysql_fetch_array($result);

$title_news = stripslashes($myrow["title_news"]);
$izoh_news = stripslashes($myrow["izoh_news"]);
$text_news = stripslashes($myrow["text_news"]);
$img_news = $myrow["img_news"];
$id_news = $myrow["id_news"];
?>

<fieldset>
<legend style="color:#728D9E">Sahifaga yangi matnlar kiritish</legend>

<form name="myform" action="" method="post" enctype="multipart/form-data">
<table width="90%" border="0" cellspacing="7" cellpadding="3">
  <tr>
    <td>Sahifa Sarlavhasi: <br />
    <input name="title" type="text" size="40" value="<? echo $title_news ?>"/></td>
  </tr>
  <tr>
    <td>Text (Qisqacha mazmuni):<br />
<textarea cols="100" rows="5" name="izoh"><? echo $izoh_news; ?>
</textarea>    
    </td>
  </tr>
  <tr>
    <td>Text (Batafsil):<br />
<textarea cols="100" rows="25" name="text"><? echo $text_news; ?></textarea>  
    </td>
  </tr>
  <tr>
    <td>Mavjud Rasm: <br />
    <input name="img" type="text" size="40" value="<? echo $img_news; ?>"/><br /><br />
    Yangi Rasm<br />
	<input type="file" name="foto_news" size="30" /><br />
    
    <input name="id" type="hidden" value="<? echo $id_news; ?>" />    
    </td>
  </tr>
  <tr>
    <td>
    <input type="submit" name="send" value=" Saqlash " />
	</td>
  </tr>
</table>
</form>
<br /><a href="javascript: history.back()">Orqaga qaytish</a>
</fieldset>
<?php 
}
?>

</div>
	<!-- right col finish -->
    </td>
  </tr>
</table>


    <!-- contant finish -->
    </td>
  </tr>
</table>
<!-- futer start -->
<?php include("includes/futer.php"); ?>
<!-- futer finish -->
</div>
</body>
</html>
